package com.sdp.right.db.sys_role_menu.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sdp.core.bizc.db.IViewQuery;
import com.sdp.core.bizc.vo.DataCenter;
import com.sdp.right.db.sys_role_menu.mapper.SysRoleMenuMapper;
import com.sdp.right.db.sys_role_menu.mapper.SysRoleMenuViewMapper;
import com.sdp.right.db.sys_role_menu.service.ISysRoleMenuService;
import com.sdp.right.entity.SysRoleMenu;
import com.sdp.right.service.RemoveSystemService;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zsp
 * @since 2023-10-12
 */
@Service
@DS(value="right")
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements ISysRoleMenuService ,IViewQuery,RemoveSystemService{

	@Autowired
	private SysRoleMenuViewMapper sysRoleMenuViewMapper;

	@Override
	public <T> List<T> viewList(QueryWrapper<T> queryWrapper,DataCenter dc) {
		return sysRoleMenuViewMapper.viewList(queryWrapper);
	}

	@Override
	public <T> int viewCount(QueryWrapper<T> queryWrapper) {
		return sysRoleMenuViewMapper.viewCount(queryWrapper);
	}

	@Override
	public <T> IPage<T> viewPage(IPage<T> page, QueryWrapper<T> queryWrapper,DataCenter dc) {
		return sysRoleMenuViewMapper.viewPage(page, queryWrapper);
	}

	@Override
	public void removeSysRoleMenuByMenu(String menuNo) {
		LambdaQueryWrapper<SysRoleMenu> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(SysRoleMenu::getMenuNo, menuNo);
		remove(queryWrapper);
	}

	@Override
	public void removeSysRoleMenuByRoleNo(String roleNo) {
		LambdaQueryWrapper<SysRoleMenu> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(SysRoleMenu::getRoleNo, roleNo);
		remove(queryWrapper);
		
	}

	@Override
	public List<SysRoleMenu> querySysRoleMenu(String roleNo) {
		LambdaQueryWrapper<SysRoleMenu> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(SysRoleMenu::getRoleNo, roleNo);
		return list(queryWrapper);
	}

	@Override
	public void removeSysRoleMenu(String systemNo, String roleNo) {
		LambdaQueryWrapper<SysRoleMenu> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(SysRoleMenu::getRoleNo, roleNo);
		queryWrapper.eq(SysRoleMenu::getSystemNo, systemNo);
		remove(queryWrapper);
		
	}

	@Override
	public void removeBySystemNo(String systemNo) {
		LambdaQueryWrapper<SysRoleMenu> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(SysRoleMenu::getSystemNo, systemNo);
		remove(queryWrapper);
	}
	
	

}
